package com.leave.service;

import com.leave.dao.LeaveDao;
import com.leave.entity.Classes;
import com.leave.entity.Course;
import com.leave.entity.Leave;

import java.util.List;

public class LeaveService {
    private LeaveDao leaveDao;
    public List<Leave> listleave(Leave leave){
        List<Leave> list =null;
        list =leaveDao.query(leave);
        return list;
    }

//    public List<Leave> leaveAuditList(Leave leave){
//        List<Leave> list =null;
//        list =leaveDao.query(leave);
//        return list;
//    }

    public List<Leave> seek(String courseID) {
        Leave leave=new Leave();
        leave.setCourseID(courseID);
        List<Leave> list =leaveDao.query(leave);
        return list;

    }

    public List<Leave> seekClassID(String classesID) {
        Course course = new Course();
        course.setClassID(classesID);
        return leaveDao.queryByClassID(classesID);
    }

    public List<Leave> seekTerm(String term) {
        Course course = new Course();
        course.setTerm(term);
//        Leave leave = new Leave();
        return leaveDao.queryByTerm(term);
    }

    public List<Leave> seekByClassIDAndTerm(String classID,String term){
        Course course = new Course();
        course.setClassID(classID);
        course.setTerm(term);
        System.out.println(classID+term);
        return leaveDao.seekByClassIDAndTerm(classID, term);
    }

    public boolean editLeave(Leave leave) {
        leaveDao.update(leave);
        return true;
    }

    public boolean addLeave(Leave leave){
      leaveDao.insert(leave);
      return true;
    }
    public void deleteLeave(String leaveID){
        leaveDao.delete(leaveID);
    }

    public void setLeaveDao(LeaveDao leaveDao) {
        this.leaveDao=leaveDao;
    }
}
